package com.ruoyi.report_jl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.syrw.annotation.FIllBasicInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.report_jl.domain.bo.ReportJlXjlsdljlbBsInfoBo;
import com.ruoyi.report_jl.domain.vo.ReportJlXjlsdljlbBsInfoVo;
import com.ruoyi.report_jl.domain.ReportJlXjlsdljlbBsInfo;
import com.ruoyi.report_jl.mapper.ReportJlXjlsdljlbBsInfoMapper;
import com.ruoyi.report_jl.service.IReportJlXjlsdljlbBsInfoService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 细集料砂当量 亚甲蓝 棱角性（流动时间法）记录Service业务层处理
 *
 * @author tll
 * @date 2024-07-31
 */
@RequiredArgsConstructor
@Service
public class ReportJlXjlsdljlbBsInfoServiceImpl implements IReportJlXjlsdljlbBsInfoService {

    private final ReportJlXjlsdljlbBsInfoMapper baseMapper;

    /**
     * 查询细集料砂当量 亚甲蓝 棱角性（流动时间法）记录
     */
    @Override
    @FIllBasicInfo
    public ReportJlXjlsdljlbBsInfoVo queryById(Long excelId){
        ReportJlXjlsdljlbBsInfoVo vo = baseMapper.selectVoById(excelId);
        return vo;
    }

    /**
     * 查询细集料砂当量 亚甲蓝 棱角性（流动时间法）记录列表
     */
    @Override
    public TableDataInfo<ReportJlXjlsdljlbBsInfoVo> queryPageList(ReportJlXjlsdljlbBsInfoBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<ReportJlXjlsdljlbBsInfo> lqw = buildQueryWrapper(bo);
        Page<ReportJlXjlsdljlbBsInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询细集料砂当量 亚甲蓝 棱角性（流动时间法）记录列表
     */
    @Override
    public List<ReportJlXjlsdljlbBsInfoVo> queryList(ReportJlXjlsdljlbBsInfoBo bo) {
        LambdaQueryWrapper<ReportJlXjlsdljlbBsInfo> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<ReportJlXjlsdljlbBsInfo> buildQueryWrapper(ReportJlXjlsdljlbBsInfoBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportJlXjlsdljlbBsInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getTotalPage() != null, ReportJlXjlsdljlbBsInfo::getTotalPage, bo.getTotalPage());
        lqw.eq(bo.getPage() != null, ReportJlXjlsdljlbBsInfo::getPage, bo.getPage());
        lqw.eq(StringUtils.isNotBlank(bo.getJilbh()), ReportJlXjlsdljlbBsInfo::getJilbh, bo.getJilbh());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancdwmc()), ReportJlXjlsdljlbBsInfo::getJiancdwmc, bo.getJiancdwmc());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcbwyt()), ReportJlXjlsdljlbBsInfo::getGongcbwyt, bo.getGongcbwyt());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpmc()), ReportJlXjlsdljlbBsInfo::getYangpmc, bo.getYangpmc());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpbh()), ReportJlXjlsdljlbBsInfo::getYangpbh, bo.getYangpbh());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpsl()), ReportJlXjlsdljlbBsInfo::getYangpsl, bo.getYangpsl());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpzt()), ReportJlXjlsdljlbBsInfo::getYangpzt, bo.getYangpzt());
        lqw.eq(bo.getYangpsj() != null, ReportJlXjlsdljlbBsInfo::getYangpsj, bo.getYangpsj());
        lqw.eq(StringUtils.isNotBlank(bo.getShiyjcrq()), ReportJlXjlsdljlbBsInfo::getShiyjcrq, bo.getShiyjcrq());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjwd()), ReportJlXjlsdljlbBsInfo::getShiytjwd, bo.getShiytjwd());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjsd()), ReportJlXjlsdljlbBsInfo::getShiytjsd, bo.getShiytjsd());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyj()), ReportJlXjlsdljlbBsInfo::getJiancyj, bo.getJiancyj());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyj()), ReportJlXjlsdljlbBsInfo::getPandyj, bo.getPandyj());
        lqw.eq(StringUtils.isNotBlank(bo.getZhuyyqsbmcjbh()), ReportJlXjlsdljlbBsInfo::getZhuyyqsbmcjbh, bo.getZhuyyqsbmcjbh());
        lqw.eq(StringUtils.isNotBlank(bo.getFujsm()), ReportJlXjlsdljlbBsInfo::getFujsm, bo.getFujsm());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobmc()), ReportJlXjlsdljlbBsInfo::getBaobmc, bo.getBaobmc());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobbh()), ReportJlXjlsdljlbBsInfo::getBaobbh, bo.getBaobbh());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcmc()), ReportJlXjlsdljlbBsInfo::getGongcmc, bo.getGongcmc());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancr()), ReportJlXjlsdljlbBsInfo::getJiancr, bo.getJiancr());
        lqw.eq(StringUtils.isNotBlank(bo.getJilr()), ReportJlXjlsdljlbBsInfo::getJilr, bo.getJilr());
        lqw.eq(StringUtils.isNotBlank(bo.getFuhr()), ReportJlXjlsdljlbBsInfo::getFuhr, bo.getFuhr());
        lqw.eq(bo.getRiq() != null, ReportJlXjlsdljlbBsInfo::getRiq, bo.getRiq());
        lqw.eq(StringUtils.isNotBlank(bo.getShebIds()), ReportJlXjlsdljlbBsInfo::getShebIds, bo.getShebIds());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyjIds()), ReportJlXjlsdljlbBsInfo::getJiancyjIds, bo.getJiancyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyjIds()), ReportJlXjlsdljlbBsInfo::getPandyjIds, bo.getPandyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getShadlPzsj()), ReportJlXjlsdljlbBsInfo::getShadlPzsj, bo.getShadlPzsj());
        lqw.eq(bo.getShadlLhg() != null, ReportJlXjlsdljlbBsInfo::getShadlLhg, bo.getShadlLhg());
        lqw.eq(bo.getShadlGy() != null, ReportJlXjlsdljlbBsInfo::getShadlGy, bo.getShadlGy());
        lqw.eq(bo.getShadlJq() != null, ReportJlXjlsdljlbBsInfo::getShadlJq, bo.getShadlJq());
        lqw.eq(bo.getShadlPzsl() != null, ReportJlXjlsdljlbBsInfo::getShadlPzsl, bo.getShadlPzsl());
        lqw.eq(StringUtils.isNotBlank(bo.getShadlSycs1()), ReportJlXjlsdljlbBsInfo::getShadlSycs1, bo.getShadlSycs1());
        lqw.eq(bo.getShadlSzl1() != null, ReportJlXjlsdljlbBsInfo::getShadlSzl1, bo.getShadlSzl1());
        lqw.eq(bo.getShadlH11() != null, ReportJlXjlsdljlbBsInfo::getShadlH11, bo.getShadlH11());
        lqw.eq(bo.getShadlH21() != null, ReportJlXjlsdljlbBsInfo::getShadlH21, bo.getShadlH21());
        lqw.eq(bo.getShadlWd1() != null, ReportJlXjlsdljlbBsInfo::getShadlWd1, bo.getShadlWd1());
        lqw.eq(bo.getShadlCz1() != null, ReportJlXjlsdljlbBsInfo::getShadlCz1, bo.getShadlCz1());
        lqw.eq(StringUtils.isNotBlank(bo.getShadlSycs2()), ReportJlXjlsdljlbBsInfo::getShadlSycs2, bo.getShadlSycs2());
        lqw.eq(bo.getShadlSzl2() != null, ReportJlXjlsdljlbBsInfo::getShadlSzl2, bo.getShadlSzl2());
        lqw.eq(bo.getShadlH12() != null, ReportJlXjlsdljlbBsInfo::getShadlH12, bo.getShadlH12());
        lqw.eq(bo.getShadlH22() != null, ReportJlXjlsdljlbBsInfo::getShadlH22, bo.getShadlH22());
        lqw.eq(bo.getShadlWd2() != null, ReportJlXjlsdljlbBsInfo::getShadlWd2, bo.getShadlWd2());
        lqw.eq(bo.getShadlCz2() != null, ReportJlXjlsdljlbBsInfo::getShadlCz2, bo.getShadlCz2());
        lqw.eq(bo.getShadlPjz() != null, ReportJlXjlsdljlbBsInfo::getShadlPjz, bo.getShadlPjz());
        lqw.eq(bo.getYajlZlmh() != null, ReportJlXjlsdljlbBsInfo::getYajlZlmh, bo.getYajlZlmh());
        lqw.eq(bo.getYajlZlmg() != null, ReportJlXjlsdljlbBsInfo::getYajlZlmg, bo.getYajlZlmg());
        lqw.eq(bo.getYajlHsl() != null, ReportJlXjlsdljlbBsInfo::getYajlHsl, bo.getYajlHsl());
        lqw.eq(bo.getYajlZl1l() != null, ReportJlXjlsdljlbBsInfo::getYajlZl1l, bo.getYajlZl1l());
        lqw.eq(bo.getYajlCdzmg() != null, ReportJlXjlsdljlbBsInfo::getYajlCdzmg, bo.getYajlCdzmg());
        lqw.eq(bo.getYajlCdzml() != null, ReportJlXjlsdljlbBsInfo::getYajlCdzml, bo.getYajlCdzml());
        lqw.eq(bo.getYajlCdzg() != null, ReportJlXjlsdljlbBsInfo::getYajlCdzg, bo.getYajlCdzg());
        lqw.eq(bo.getYajlX015mg() != null, ReportJlXjlsdljlbBsInfo::getYajlX015mg, bo.getYajlX015mg());
        lqw.eq(bo.getYajlX015ml() != null, ReportJlXjlsdljlbBsInfo::getYajlX015ml, bo.getYajlX015ml());
        lqw.eq(bo.getYajlX015g() != null, ReportJlXjlsdljlbBsInfo::getYajlX015g, bo.getYajlX015g());
        lqw.eq(bo.getYajlPjmg() != null, ReportJlXjlsdljlbBsInfo::getYajlPjmg, bo.getYajlPjmg());
        lqw.eq(bo.getYajlPjml() != null, ReportJlXjlsdljlbBsInfo::getYajlPjml, bo.getYajlPjml());
        lqw.eq(StringUtils.isNotBlank(bo.getYajlPjlz()), ReportJlXjlsdljlbBsInfo::getYajlPjlz, bo.getYajlPjlz());
        lqw.eq(StringUtils.isNotBlank(bo.getLengjSycs1()), ReportJlXjlsdljlbBsInfo::getLengjSycs1, bo.getLengjSycs1());
        lqw.eq(bo.getLengjMd1() != null, ReportJlXjlsdljlbBsInfo::getLengjMd1, bo.getLengjMd1());
        lqw.eq(bo.getLengjMg1() != null, ReportJlXjlsdljlbBsInfo::getLengjMg1, bo.getLengjMg1());
        lqw.eq(bo.getLengjCz1() != null, ReportJlXjlsdljlbBsInfo::getLengjCz1, bo.getLengjCz1());
        lqw.eq(StringUtils.isNotBlank(bo.getLengjSycs2()), ReportJlXjlsdljlbBsInfo::getLengjSycs2, bo.getLengjSycs2());
        lqw.eq(bo.getLengjMd2() != null, ReportJlXjlsdljlbBsInfo::getLengjMd2, bo.getLengjMd2());
        lqw.eq(bo.getLengjMg2() != null, ReportJlXjlsdljlbBsInfo::getLengjMg2, bo.getLengjMg2());
        lqw.eq(bo.getLengjCz2() != null, ReportJlXjlsdljlbBsInfo::getLengjCz2, bo.getLengjCz2());
        lqw.eq(StringUtils.isNotBlank(bo.getLengjSycs3()), ReportJlXjlsdljlbBsInfo::getLengjSycs3, bo.getLengjSycs3());
        lqw.eq(bo.getLengjMd3() != null, ReportJlXjlsdljlbBsInfo::getLengjMd3, bo.getLengjMd3());
        lqw.eq(bo.getLengjMg3() != null, ReportJlXjlsdljlbBsInfo::getLengjMg3, bo.getLengjMg3());
        lqw.eq(bo.getLengjCz3() != null, ReportJlXjlsdljlbBsInfo::getLengjCz3, bo.getLengjCz3());
        lqw.eq(StringUtils.isNotBlank(bo.getLengjSycs4()), ReportJlXjlsdljlbBsInfo::getLengjSycs4, bo.getLengjSycs4());
        lqw.eq(bo.getLengjMd4() != null, ReportJlXjlsdljlbBsInfo::getLengjMd4, bo.getLengjMd4());
        lqw.eq(bo.getLengjMg4() != null, ReportJlXjlsdljlbBsInfo::getLengjMg4, bo.getLengjMg4());
        lqw.eq(bo.getLengjCz4() != null, ReportJlXjlsdljlbBsInfo::getLengjCz4, bo.getLengjCz4());
        lqw.eq(StringUtils.isNotBlank(bo.getLengjSycs5()), ReportJlXjlsdljlbBsInfo::getLengjSycs5, bo.getLengjSycs5());
        lqw.eq(bo.getLengjMd5() != null, ReportJlXjlsdljlbBsInfo::getLengjMd5, bo.getLengjMd5());
        lqw.eq(bo.getLengjMg5() != null, ReportJlXjlsdljlbBsInfo::getLengjMg5, bo.getLengjMg5());
        lqw.eq(bo.getLengjCz5() != null, ReportJlXjlsdljlbBsInfo::getLengjCz5, bo.getLengjCz5());
        lqw.eq(bo.getLengjPjz() != null, ReportJlXjlsdljlbBsInfo::getLengjPjz, bo.getLengjPjz());
        return lqw;
    }

    /**
     * 新增细集料砂当量 亚甲蓝 棱角性（流动时间法）记录
     */
    @Override
    public Boolean insertByBo(ReportJlXjlsdljlbBsInfoBo bo) {
        ReportJlXjlsdljlbBsInfo add = BeanUtil.toBean(bo, ReportJlXjlsdljlbBsInfo.class);
        validEntityBeforeSave(add);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setExcelId(add.getExcelId());
        }
        return flag;
    }

    /**
     * 修改细集料砂当量 亚甲蓝 棱角性（流动时间法）记录
     */
    @Override
    public Boolean updateByBo(ReportJlXjlsdljlbBsInfoBo bo) {
        ReportJlXjlsdljlbBsInfo update = BeanUtil.toBean(bo, ReportJlXjlsdljlbBsInfo.class);
        validEntityBeforeSave(update);
        return baseMapper.updateById(update) > 0;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ReportJlXjlsdljlbBsInfo entity){
        //TODO 做一些数据校验,如唯一约束
    }

    /**
     * 批量删除细集料砂当量 亚甲蓝 棱角性（流动时间法）记录
     */
    @Override
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
        if(isValid){
            //TODO 做一些业务上的校验,判断是否需要校验
        }
        return baseMapper.deleteBatchIds(ids) > 0;
    }
}
